package com.account.validate;

import java.util.regex.Matcher;
import java.util.regex.Pattern;



public class RegistrationValidator {
	private Pattern patternEmail;
	private Matcher matcher;
	private Pattern patternFirstName;
	private Pattern patternLastName;
	private Pattern patternThikana;
	private Pattern patternFatherName;
	private Pattern patternStatus;
	private Pattern patternQualification;
	
	public String name;
	public String mailid;
	public String firstName;
	public String lastName;
	public String fatherName;
	public String villAge;
	public String statusValue;
	public String qualification;
	private static final String EMAIL_VALIDATOR=
			"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
					+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
	
	private static final String FIRST_NAME_VALIDATOR=
			"^[a-zA-z ]*$";
	private static final String LAST_NAME_VALIDATOR=
			"[A-Z][a-zA-Z]*";
	private static final String THIKANA_VALIDATOR=
			"[A-Z][a-zA-Z]*";
	private static final String FATHER_NAME_VALIDATOR=
			"^[a-zA-z ]*$";
	private static final String STATUS_VALIDATOR=
			"^[a-zA-z ]*$";
	private static final String QUALIFICATION_VALIDATOR=
			"[A-Z][a-zA-Z]*";
	public void RegisationtrValidator(){
		patternEmail=Pattern.compile(EMAIL_VALIDATOR);
		patternFirstName=Pattern.compile(FIRST_NAME_VALIDATOR);
		patternLastName=Pattern.compile(LAST_NAME_VALIDATOR);
		patternThikana=Pattern.compile(THIKANA_VALIDATOR);
		patternFatherName=Pattern.compile(FATHER_NAME_VALIDATOR);
		patternStatus=Pattern.compile(STATUS_VALIDATOR);
		patternQualification=Pattern.compile(QUALIFICATION_VALIDATOR);
	}
	
	public boolean isEmailValidator(String emailid){
		matcher=patternEmail.matcher(emailid);
		
		return matcher.matches();
	}
	public boolean isUserDetail(String firstname, String lastname, String thikana, String fathername, String status, String education){
		matcher=patternFirstName.matcher(firstname);
		matcher=patternLastName.matcher(lastname);
		matcher=patternThikana.matcher(thikana);
		matcher=patternFatherName.matcher(fathername);
		matcher=patternStatus.matcher(status);
		matcher=patternQualification.matcher(education);
		
		boolean firstName=matcher.matches();
		boolean lastName=matcher.matches();
		boolean villAge=matcher.matches();
		boolean fatherName=matcher.matches();
		boolean statusValue=matcher.matches();
		boolean qualification=matcher.matches();
		if((firstName)&&(lastName)&&(villAge)&&(fatherName)&&(statusValue)&&(qualification)){
			
			return true;
		}
		else{
			return false;
		}
		
	}
	public String setFirstName(String name)
	{
		this.name=name;
		return name;
	}
			
}
